import http from "../../utils/request"
import type { Administrator, IRole, LoginResponse, MenuResponse, RoleParams, RoleReponse, VerifyCode } from "./type";

/**
 * 获取验证码
 */
export const getverifyCode = () => {

    return http.get<VerifyCode>("auth/VerifyCode");
}

/**
 * 登录
 */
export const login = (data: Administrator) => {
    return http.post<LoginResponse, Administrator>("administrator/checkloginByCode", data);
}

 
/**
 * 获取角色列表
 * 
 */
export const getRoleList = (params:RoleParams) => {
    return http.get<RoleReponse>("administratorrole/list",params);
}

//获取权限列表
export const getPermissionList = () => {
    return http.get<MenuResponse>("menu/list");
}

/**
 * 添加角色
 * 
 */
export const addRole = (data:IRole) => {
    return http.post<any>("administratorrole/add", data);
}



export const getMenuIdByRoleId = (roleid:number) => {
    return http.get<any>("menu/getMenuIdByRoleId", {roleid});
}
